﻿<div style="background:#fbf9fe" ms-controller="CPGL">
    <div ms-if="isHasDataQX=='Y'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品名称</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ms-duplex="modelData.Name" type="text" placeholder="(必填)" class="weui_input szhl szhl_require" />
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品编号</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ms-duplex="modelData.BianHao" type="text" placeholder="(必填)" class="weui_input szhl szhl_require" />
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">标准单价</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ms-duplex="modelData.Price" type="number" class="weui_input szhl szhl_require szhl_Float" placeholder="(必填)" />
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">销售单位</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ms-duplex="modelData.DanWei" type="text" placeholder="(必填)" class="weui_input " />
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品分类</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <select ms-duplex="modelData.LeiBie" class="szhl szhl_require weui-select">
                        <option ms-repeat-item="ColumnData" ms-attr-value="item.ID">{{item.TypeName}}</option>
                    </select>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">单位成本</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ms-duplex="modelData.ChengBen" type="text" class="weui_input" placeholder="(必填)" />
                </div>
            </div>
            <div class="extdiv"></div>
        </div>
        
        <div class="weui_cells_title">产品介绍</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea ms-duplex="modelData.PContent" rows="3" class="weui_textarea" placeholder="请输入产品介绍"></textarea>
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <input type="text" ms-duplex="modelData.Files" class="wximgupload" style="display:none;" />
                </div>
            </div>
        </div>
    </div>
    <div ms-if="isHasDataQX=='N'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品名称</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.Name}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品编号</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.BianHao}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">标准单价</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    ￥{{modelData.Price}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">销售单位</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.DanWei}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">产品分类</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.TypeName}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">单位成本</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.ChengBen}}
                </div>
            </div>

        </div>
        <div class="extdiv"></div>
        <div class="weui_cells_title">产品介绍</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.PContent|html}}
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <div class="viewimg">{{modelData.Files}}</div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--<div class="list-block" style="margin: 0;" ms-controller="CPGL">
    <ul ms-if="isHasDataQX=='Y'">
        <li>
            <div class="item-content ">
                <div class="item-inner">
                    <div class="item-title label">产品名称</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Name" type="text" placeholder="请输入产品名称" class="szhl szhl_require" />
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">产品编号</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.BianHao" type="text" placeholder="请输入产品编号" class="szhl szhl_require" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">标准单价</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Price" type="text" class="szhl szhl_Float" placeholder="请输入标准单价" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">销售单位</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.DanWei" type="text" placeholder="请输入销售单位" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">单位成本</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.ChengBen" type="text" placeholder="请输入单位成本" />

                    </div>
                </div>
            </div>
        </li>

        <li>
            <div class="item-content item-link">
                <div class="item-inner">
                    <div class="item-title label">产品分类</div>
                    <div class="item-input">
                        <select ms-duplex="modelData.LeiBie" class="szhl szhl_require">
                            <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.LeiBie?'selected':''">{{item.TypeName}}</option>
                        </select>
                    </div>
                </div>
            </div>
        </li>
        <li class="align-top">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">图片</div>
                    <div class="item-input">
                        <input type="text" ms-duplex="modelData.Files" class="wximgupload" style="display:none;" />
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">产品介绍</div>
                    <div class="item-input">
                        <textarea ms-duplex="modelData.PContent" rows="3" placeholder="请输入产品介绍"></textarea>
                    </div>
                </div>
            </div>
        </li>
    </ul>

    <ul ms-if="isHasDataQX=='N'">
        <li ms-if="modelData.Name">
            <div class="item-content ">
                <div class="item-inner">
                    <div class="item-title label">产品名称</div>
                    <div class="item-input">
                        {{modelData.Name}}
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.BianHao">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">产品编号</div>
                    <div class="item-input">
                        {{modelData.BianHao}}
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Price">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">标准单价</div>
                    <div class="item-input">
                        {{modelData.Price}}

                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.DanWei">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">销售单位</div>
                    <div class="item-input">
                        {{modelData.DanWei}}
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.ChengBen">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">单位成本</div>
                    <div class="item-input">
                        {{modelData.ChengBen}}

                    </div>
                </div>
            </div>
        </li>

        <li ms-if="modelData.TypeName">
            <div class="item-content item-link">
                <div class="item-inner">
                    <div class="item-title label">产品分类</div>
                    <div class="item-input">
                        {{modelData.TypeName}}
                    </div>
                </div>
            </div>
        </li>
        <li class="align-top" ms-if="modelData.Files">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">图片</div>
                    <div class="item-input">
                        <div class="viewimg">{{modelData.Files}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.PContent">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">产品介绍</div>
                    <div class="item-input" >
                        {{modelData.PContent|html}}
                    </div>
                </div>
            </div>
        </li>
    </ul>
</div>-->
<script>
    var tempmodel = avalon.define({
        $id: "CPGL",
        ColumnData: [],
        name: "产品管理",
        tpData: [],
        wximg: "",
        dataid: "",
        inittemp: function (strId) {

            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETZIDIANLIST', { P1: 15 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result;
                    if (!tempmodel.modelData.LeiBie) {
                        tempmodel.modelData.LeiBie = resultData.Result[0].ID
                    };
                }
            })
            if (strId) {

                tempmodel.dataid = strId;
                $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETCPMODEL', { P1: strId }, function (resultData) {

                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        tempmodel.tpData = resultData.Result1;

                        ComFunJS.uploadimgnew(tempmodel.tpData);
                        ComFunJS.viewimg(tempmodel.tpData);
                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else {

                ComFunJS.uploadimgnew();
                ComFunJS.initForm();
            }
        },//初始化
        modelData: { "PContent": "", "Name": "", "BianHao": "", "Price": "", "DanWei": "", "ChengBen": "", "LeiBie": "", "Files": "" },
        SaveData: function (callback) {

            tempmodel.modelData.Files = "";
            $("#imglist .tpli").each(function () {
                if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                    if (tempmodel.wximg) {
                        tempmodel.wximg += ",";
                    }
                    tempmodel.wximg += $(this).attr("itemid");

                } else {
                    if (tempmodel.modelData.Files) {
                        tempmodel.modelData.Files = tempmodel.modelData.Files + ',' + $(this).attr("itemid");
                    }
                    else {
                        tempmodel.modelData.Files = $(this).attr("itemid");
                    }
                }

            })

            $.post("/API/VIEWAPI.ashx?ACTION=CRM_ADDCP", { P1: JSON.stringify(tempmodel.modelData.$model), P2: tempmodel.wximg }, function (result) {
                return callback.call(this, $.parseJSON(result));
            });
        },
        Complate: function () {
            window.location.href = "/View_Mobile/UI/CRM/UI_CPGL_LIST.html?r=" + Math.random();
        }
    });//@ sourceURL=MCPGL.js;

</script>